import { Method } from 'alova'

export type AlovaConf = {
    errors: (error: CompositionError) => any
    reLogin: () => any
    onSuccess: (response: Response, method: Method) => any
    onError: (err: any, method: Method) => any
} & Env

export type CompositionError = Error | { msg?: string } | string

export type EnvKeys = 'beta' | 'release' | 'dev'

export type Mode = 'development' | 'production' | EnvKeys

export interface Env {
    baseURL: string
    apiPath: string
    host: string
    local: boolean
    key: EnvKeys
    isDev: boolean
    uploadHost: string
}

export interface ServeJson<T = unknown> {
    code: number
    msg: string
    data: T
}

export type ServerData<T = unknown> = ServeJson<T> | Blob

export interface Data<T = any> {
    ok: boolean
    data: ServerData<T>
}
